package com.gxy.learn.web;

import com.gxy.learn.feign.ProviderClient;
import com.gxy.learn.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class TestFeignController {

    @Autowired
    private ProviderClient providerClient;
    @Autowired
    private OrderService orderService;

    /**
     * 利用spring.application.name来调用接口
     * @return
     */
    @GetMapping("/feign/test")
    public String test() {
        String result = providerClient.hello("gaoxueyong");
        String retRes = String.format("return : %s", result);
        log.info(retRes);
        return retRes;
    }

    @GetMapping("/feign/globalTransactionalTest")
    public String globalTransactionalTest() {
        orderService.testCreatOrder();
        return "ok";
    }

}
